package org.shijiagen.manager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import org.shijiagen.constants.UserConstants;
import org.shijiagen.manager.mapper.AdminUserMapper;
import org.shijiagen.manager.param.AdminUserParam;
import org.shijiagen.manager.pojo.AdminUser;
import org.shijiagen.manager.service.AdminUserService;
import org.shijiagen.utils.MD5Util;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class AdminUserServiceImpl implements AdminUserService {

    private final AdminUserMapper adminUserMapper;

    @Override
    public AdminUser login(AdminUserParam adminUserParam) {
        return adminUserMapper.selectOne(new QueryWrapper<AdminUser>()
                .eq("user_account",adminUserParam.getUserAccount())
                .eq("user_password", MD5Util.encode(adminUserParam.getUserPassword() + UserConstants.USER_SALT)));
    }
}
